import { useContext, useEffect } from 'react';
import { sub2Content } from '../index';
export default function Test1() {
  const context = useContext(sub2Content);
  const a = () => {
    console.log('a函数');
  };

  const b = () => {
    return new Promise((resolve, reject) => {
      setTimeout(() => {
        resolve(2)
      }, 1000);
    })
  };

  const loading = async () => {
    console.log(111);
    await a();
    if(true) {
      await b()
    }
    console.log(444);
  };

  // const e = () => {
  //   yield 5
  //   yield 6
  // }

  function* c() {
    yield 1
    yield 2
  } 

  function* d() {
    yield 3
    yield* c()
    yield 4
  }

  useEffect(() => {
    loading();
    // for(let i of d()) {
    //   console.log(i);
    // }
    // let d1 = d()
    // console.log(d1.next());
    // console.log(d1.next());
    // console.log(d1.next());
    // console.log(d1.next());
  }, []);

  return <div>test1,{context.a},{context.b}</div>;
}
